/**
 * 中农-红点优家-花名册管理
 * */
Ext.namespace('pages.p2p.zn.hdyj.UploadExcel');

pages.p2p.zn.hdyj.UploadExcel.Main = function(config) {
	Ext.apply(this, config);
	this.initUIComponents();
	pages.p2p.zn.hdyj.UploadExcel.Main.superclass.constructor.call(this);
};

Ext.extend(pages.p2p.zn.hdyj.UploadExcel.Main, Ext.Window, {
	/**
	 * 构造函数
	 */
	initUIComponents : function() {

		this.form = new Ext.form.FormPanel({
					fileUpload: true,
					layout : 'column',
					labelWidth : 100,
					labelAlign : 'right',
					autoHeight : true,
					border : false,
					frame : false,
					items : [{
								columnWidth : 1,
								height : 10,
								border : false
							},{
								columnWidth : .99,
								layout : 'form',
								border : false,
								items : [{
									 	xtype : 'textfield',
								        fieldLabel : '上传文件名',
								        allowBlank : false,  
								        name : 'filename',
								        id : 'filename',
								        inputType : 'file',
								        blankText : 'File can\'t not empty.',
								        anchor : '96%' // anchor width by percentage
										}]
							}],
					buttons : [{
						text : '提交',
						handler : function(){
							this.form.getForm().submit({  
					            url: ExtJ.getActionPath('zn/importExcel_Hmc.do'),  
					            method:'POST',
					            timeout:90000,
					            waitMsg:'数据上传中, 请稍等...',  
					            success:function(form, action, o) {
					                Ext.MessageBox.alert("提示信息",action.result.msg);  
					                Ext.getCmp('uploadExcelWin').close();
					            },  
					            failure : function(form, action) {  
					                Ext.MessageBox.alert("提示信息","请求失败,文件上传失败！</br> " + action.result.msg);  
					            }  
					        });  
						}.createDelegate(this)
					},{
						text : '关闭',
						handler : function(){
							Ext.getCmp('uploadExcelWin').close();
						}.createDelegate(this)
					}]
				});


		Ext.apply(this, {
					title : '花名册导入',
					layout : 'fit',
					id : 'uploadExcelWin',
					width : 400,
					height : 100,
					border : false,
					closeAction: 'close',
					modal:true,
					listeners : {
						'render' : this.initData.createDelegate(this)
					},
					items : [this.form]
				})
	},

	initData : function() {
	},

	onReset : function() {
		this.form.getForm().reset();
	}
	
});